<?php

require_once './include/common.inc.php';

$page_title = 'jans2en furniture - New Items - New Items';
$menu_id = 7;
checkLogin();


$categor_name = "New Items";
$sql_where1 = '`new_flag`=1';

// *** page code start ***
$page_url = 'new_items.php?';
//$sql = "SELECT `id` FROM `product` WHERE " . $sql_where1 . " AND `hidden_flag`=0";
$sql = "SELECT p.`id` FROM `product` p, `product_category` pc, `category` c WHERE not exists(select id from category where id=c.fid and publish = 0) AND  c.`id`=pc.`category_id` AND pc.`product_id`=p.`id` AND p.`new_flag`=1 AND p.`hidden_flag`=0 GROUP BY p.`id`";
$query = $db->query($sql);
$sql_all_num = $db->num_rows($query);

$ppp = 12;
getMyParam('page');
$page = empty($page) || !ispage($page) ? 1 : $page;
$start_limit = ($page - 1) * $ppp;
if($start_limit > $sql_all_num) {
    $start_limit = 0;
    $page = 1;
}

$page_show = getPhotoPageStr($sql_all_num, $page, $ppp, $page_url);
// *** page code end ***

$photo_ary = array();
//$sql = "SELECT * FROM `product` WHERE " . $sql_where1 . " AND `hidden_flag`=0 ORDER BY `id` DESC LIMIT $start_limit, $ppp";
$sql = "SELECT p.`id`, p.`code`, p.`name`, p.`pic`, p.`small_pic`, p.`price_1`, p.`price_2`, p.`price_3`, p.`new_flag` FROM `product` p, `product_category` pc, `category` c WHERE not exists(select id from category where id=c.fid and publish = 0) AND c.`id`=pc.`category_id` AND pc.`product_id`=p.`id` AND p.`new_flag`=1 AND p.`hidden_flag`=0 GROUP BY p.`id` ORDER BY c.fid ASC, c.seq ASC, pc.`seq` DESC, p.`code` DESC LIMIT $start_limit, $ppp";
$query = $db->query($sql);
while($rs = $db->fetch_array($query)) {
    $photo_ary[] = $rs;
    $js_id_ary[] = "'" . $rs['id'] . "'";
}

$js_id_ary_str = !empty($js_id_ary) ? "new Array(" . implode(',', $js_id_ary) . ")" : "new Array()";
//$category_pic_2 = 'guide_product_default.jpg';

// -------------- guideͼƬ start ----------------------------------------
$system_ary = getSystemValue("");
$guide_pic = $system_ary['picture_new_items'];
if (trim($guide_pic) == "" || !file_exists("./attachments/system/" . $guide_pic)) {
    $guide_pic = './attachments/system/no_guide.gif';
} else {
    $guide_pic = './attachments/system/' . $guide_pic;
}
// -------------- guideͼƬ end ------------------------------------------

	browseTracking(17,0,'Home > New Items'.'(page '.$page.')');
require_once PrintEot('header');
require_once PrintEot('new_items');
require_once PrintEot('footer');

?>